package com.pig4cloud.mall.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.mall.product.dto.PageParam;
import com.pig4cloud.mall.product.dto.QueryReq;
import com.pig4cloud.mall.product.entity.SkuInfo;
import com.pig4cloud.mall.product.mapper.SkuInfoMapper;
import com.pig4cloud.mall.product.service.SkuInfoService;
import com.pig4cloud.pig.common.core.util.PageResult;
import com.pig4cloud.pig.common.core.util.R;
import org.springframework.stereotype.Service;

/**
 * sku信息
 *
 * @author fangyu
 * @date 2020-11-25 14:59:10
 */
@Service
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoMapper, SkuInfo> implements SkuInfoService {

	@Override
	public R getAllBySpuId(Long spuId, PageParam params) {
		QueryWrapper<SkuInfo> wrapper = new QueryWrapper<>();
		if (spuId != null) {
			wrapper.eq("spu_id", spuId);
		}
		IPage<SkuInfo> iPage = this.page(new QueryReq<SkuInfo>().getPage(params), wrapper);
		return R.ok(PageResult.buildPage(iPage));
	}
}
